﻿@model GPS.ENTITYS.ViewModelDDTSH_KQSH
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Điểm học viên sát hạch";
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/datepicker.js"></script>

<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">Thông tin học viên thi sát hạch</h3>
    <div class="row">
        @using (Html.BeginForm("Index", "GPS_DiemHocVienSatHach", FormMethod.Get))
        {

            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều Kiện Tìm Kiếm</legend>

                    <div class="row criteria_search">
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Đơn vị đào tạo
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.pDVGTVT_MA, (SelectList)ViewBag.DVGTVT_MAs, string.Empty, new { @class = "form-control", @id = "DVGTVT_MA_dll" })
                            </div>
                        </div>
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Mã Khóa Học
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pKH_MA, new { @class = "form-control" })
                            </div>
                            <div class="col-md-2 control-label">
                                Mã lớp học
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pKH_LOP_MA, new { @class = "form-control" })
                            </div>
                        </div>
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Mã học viên
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_MA, new { @class = "form-control" })
                            </div>
                            <div class="col-md-2 control-label">
                                Họ tên
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_HOTEN, new { @class = "form-control" })
                            </div>

                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Số CMND
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_CMND, new { @class = "form-control" })
                            </div>
                            <div class="col-md-2 control-label">
                                Số báo danh
                            </div>
                            <div class="col-md-4">
                                @Html.TextBoxFor(model => model.pHV_SBD, new { @class = "form-control" })
                            </div>

                        </div>

                    </div>

                    <div class="row margin-top-05 btn_search">
                        <button type="submit" class="btn btn-warning btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                    </div>
                </fieldset>
            </div>
        }
        <br />
        <div id="dialog"></div>
        <div class="row">
            <fieldset class="fs_body">
                <legend class="head_title">Kết quả tìm kiếm</legend>

                <div class="row divbtnFielset">
                    <div style="float: left;">
                        @*@Html.NoEncodeActionLink("<span class='glyphicon glyphicon-plus'></span> Thêm mới", "Thêm mới", "Create", "GPS_DiemTotNghiep", null, htmlAttributes: new { @class = "btn btn-warning btn-sm" })*@
                        @*<button type="submit" class="btn btn-primary btn-sm" name="SearchButton" value="Xuất Excel">
                                <i class='fa fa-file-excel-o'></i> Xuất Excel
                            </button>
                            @Html.NoEncodeActionLink("<i class='fa fa-file-excel-o'></i> Import Excel", "Import Excel", "ImportExcel", "GPS_MonHoc", null, htmlAttributes: new { @class = "btn btn-primary btn-sm" })*@
                    </div>
                    <div style="float: right;">
                        <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                    </div>
                </div>

                <div class="row" style="clear:both; padding: 5px 0;">
                    <table class="table table-hover table-bordered table-condensed">
                        <tr>
                            <th>
                                Tên học viên
                            </th>

                            <th>
                                Đơn vị GTVT
                            </th>
                            <th>
                                TTSH
                            </th>
                            <th>
                                Số BD
                            </th>
                            @*<th>
                                Ngày sinh
                            </th>*@
                            <th>
                                Ngày KQSH
                            </th>
                            <th>
                                Điểm SHLT
                            </th>
                            <th>
                                Điểm SHTH
                            </th>
                            <th>
                                Điểm SHTD
                            </th>
                            <th>
                                Kết quả SH
                            </th>
                            <th></th>
                        </tr>
                        @{
                            if (Model.SearchResults != null)
                            {
                                foreach (var item in Model.SearchResults)
                                {
                                    <tr>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DTSH_KQSH_HV_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DTSH_KQSH_DVGTVT_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_DTSH_TTSH_TEN))
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_SBD))
                                        </td>
                                        @*<td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_HV_NGAYSINH))
                                        </td>*@
                                        <td>

                                            @Html.DisplayFor(modelItem => item.DTSH_KQSH_NGAYSH)

                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_LT))
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_TH))
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_TD))
                                        </td>
                                        @*<td>
                                            @Html.DisplayFor(modelItem => (item.DTSH_KQSH_NGUOINHAP))
                                        </td>*@
                                        <td>
                                            @{
                                    if (item.DTSH_KQSH_KQ  == "1")
                                    {
                                        @Html.Raw("Đạt")
                                    }
                                    else
                                    {
                                        @Html.Raw("Không đạt")
                                    }
                                            }
                                        </td>

                                        <td align="center">
                                            <div class="pull-right">
                                                @*<a href="@Url.Action("Detail", "GPS_DiemHocVienSatHach", new { id1 = item.DTSH_KQSH_DVGTVT_MA, id2 = item.DTSH_KQSH_HV_MA, id3 = item.DTSH_KQSH_DTSH_TTSH_MA, id4 = item.DTSH_KQSH_SBD })" data-modal="">
                                                    <img src="@Url.Content("~/fonts/grid-view-icon.png")" title="Xem chi tiết" />
                                                </a>*@
                                                <a href="@Url.Action("Create", "GPS_DiemHocVienSatHach", new { id1 = item.DTSH_KQSH_DVGTVT_MA, id2 = item.DTSH_KQSH_HV_MA, id3 = item.DTSH_KQSH_DTSH_TTSH_MA, id4 = item.DTSH_KQSH_SBD })" class="editDialog" data-modal="">
                                                    <img src="@Url.Content("~/fonts/grid-add-icon.png")" title="Nhập điểm sát hạch học viên" />
                                                </a>
                                                <a href="@Url.Action("Edit", "GPS_DiemHocVienSatHach", new { id1 = item.DTSH_KQSH_DVGTVT_MA, id2 = item.DTSH_KQSH_HV_MA, id = item.ID })" class="editDialog" data-modal="">
                                                    <img src="@Url.Content("~/fonts/grid-edit-icon.png")" title="Sửa điểm sát hạc học viên" />
                                                </a>
                                                <a href="@Url.Action("Delete", "GPS_DiemHocVienSatHach", new { id = item.ID, id4 = item.DTSH_KQSH_HV_MA })" onclick="return confirm('Bạn Thật Sự Muốn Xóa điểm sát hạch này Này!!!')">
                                                    <img src="@Url.Content("~/fonts/grid-delete-icon1.gif")" title="Hủy điểm sát hạch học viên" />
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                }
                            }
                        }

                    </table>
                </div>

                <div class="pagination-sm row" style="clear:both; padding: 5px 0;">
                    @Html.PagedListPager(Model.SearchResults, page => Url.Action("Index", new
   {
       page,
       Model.pDVGTVT_MA,
       Model.pKH_MA,
       Model.pKH_LOP_MA,
       Model.pHV_MA,
       Model.pHV_HOTEN,
       Model.pHV_CMND,
       Model.pHV_SBD
   }))
                </div>
            </fieldset>

        </div>
    </div>
</div>


<!-- delete modal placeholder-->
<div id='deleteModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='deleteModalContent'></div>
        </div>
    </div>
</div>

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>


@section Scripts {
    @Scripts.Render("~/bundles/modalform")
}

<script type="text/javascript">
    $.ajaxSetup({ cache: false });

    $("a[data-modal]").on("click", function (e) {
        // alert(this.href);
        $('#myModalContent').load(this.href, function () {
            // alert(this.href);

            $('#myModal').modal({
                /*backdrop: 'static',*/
                keyboard: true
            }, 'show');

            bindForm(this);
        });

        return false;
    });

    function bindForm(dialog) {

        $('form', dialog).submit(function () {
            //  alert(dialog);
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    //  alert(result.success);
                    if (result.success) {

                        $('#myModal').modal('hide');
                        //Refresh
                        location.reload();
                        //$('#replacetarget').load(result.url); //  Load data from the server and place the returned HTML into the matched element
                    } else {
                        $('#myModalContent').html(result);
                        bindForm(dialog);
                    }
                }
            });
            return false;
        });
    }

    //$(document).ready(function () {

    //    $.ajaxSetup({ cache: false });

    //    $(".editDialog").on("click", function (e) {
    //        var url = $(this).attr('href');
    //        alert(url);

    //        $("#dialog-edit").dialog({
    //            title: 'Edit Customer',
    //            autoOpen: false,
    //            resizable: false,
    //            height: 355,
    //            width: 400,
    //            show: { effect: 'drop', direction: "up" },
    //            modal: true,
    //            draggable: true,
    //            open: function (event, ui) {
    //                $(this).load(url);

    //            },
    //            close: function (event, ui) {
    //                $(this).dialog('close');
    //            }
    //        });

    //        $("#dialog-edit").dialog('open');
    //        return false;
    //    });


    //    $("#btncancel").on("click", function (e) {
    //        $("#dialog-edit").dialog('close');

    //    });
    //});
</script>

<script type="text/javascript">

    //$("#pKH_NGAYQDKG_TU").datepicker({
    //    changeMonth: true,
    //    changeYear: true,

    //    dateFormat: 'dd/mm/yy'
    //});
    //$("#pKH_NGAYQDKG_TU").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });

    //$("#pKH_NGAYQDKG_DEN").datepicker({
    //    changeMonth: true,
    //    changeYear: true,

    //    dateFormat: 'dd/mm/yy'
    //});
    //$("#pKH_NGAYQDKG_DEN").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });


    $(function () {
        $(document).tooltip();
    });

</script>


